package com.anttribe.components.db.executor.formatter;

import java.sql.Timestamp;
import java.sql.Types;
import java.text.SimpleDateFormat;

/**
 * @author zhaoyong
 * @date 2023/1/11 0011
 */
@MappedTypes(type = Types.TIMESTAMP)
public class TimestampDataFormatter extends BaseTypeDataFormatter<Timestamp> {

    /**
     * 默认时间格式化字符串
     */
    private static final String DEFAULT_TIMESTAMP_FORMAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSS";

    @Override
    protected String formatNotNull(Timestamp data) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT_PATTERN);
        return dateFormat.format(data);
    }
}
